import axios from "axios";

// 列表接口
export function fetchList(params) {
  return axios({
    url: "http://localhost:3001/data",
    method: "get",
    params,
  });
}
// 新增接口
export function add(data) {
  return axios({
    url: "http://localhost:3001/data",
    method: "post",
    data,
  });
}
// 详情接口
export function fetchDetail(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: "get",
  });
}
// 编辑接口
export function fetchUpdate(data) {
  return axios({
    url: `http://localhost:3001/data/${data.id}`,
    method: "put",
    data,
  });
}
// 删除接口
export function fetchDelete(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: "delete",
  });
}

// 搜索接口
export function fetchSearch(key) {
  return axios({
    url: `http://localhost:3001/data/?name=${key}`,
    method: "get",
  });
}
